package cn.xaut.二叉树;

import cn.xaut.剑指offer.m20.TreeNode;

/**
 * 226. 翻转二叉树
 */
public class demo226 {

    public TreeNode invertTree(TreeNode root) {

        // 递归终止条件
        if (root == null)
            return null;
        
        // 递归过程
        TreeNode node = root.right;
        root.right = invertTree(root.left);
        root.left = invertTree(node);
        
        return root;
    }

    private void swap(TreeNode left, TreeNode right) {
        
        TreeNode temp = left;
        left = right;
        right = temp;
    }
}
